package kadledav.backend;

import kadledav.backend.dto.NewsDTO;
import kadledav.backend.service.NewsService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//
//@Transactional
@Component
public class DemoData {

	Logger logger = Logger.getLogger(DemoData.class);
	
	@Autowired
	NewsService service;
	
	private void addNews(String message) {
		NewsDTO news = new NewsDTO();
		news.setMessage(message);
		logger.debug("DEMO start inserting" + news.getMessage());
		service.addNews(news);
	}

	public void runOnStart() {
		logger.info("start inserting demo data");
		addNews("Toto je prvni zprava");
		addNews("Toto je druha zprava, ktera je velice dlouha a pro jeji kompletni zobrazeni musi byt zobrazen detail. Jinak cela zprava nebude citelna");
		addNews("Toto je treti zprava");
		logger.info("end inserting demo data");
	}
}
